package com.tian.service.impl;

import com.alibaba.fastjson.JSON;
import com.tian.dto.SysLog;
import com.tian.entity.SysLogEntity;
import com.tian.mapper.SysLogMapper;
import com.tian.service.SysLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author tianwc  公众号：java后端技术全栈、面试专栏
 * @version 1.0.0
 * 博客地址：<a href="http://woaijava.cc/">博客地址</a>
 * <p>
 * 日志保存到数据库中
 */
@Slf4j
@Service
public class DatabaseSysLogServiceImpl implements SysLogService {
    @Resource
    private SysLogMapper sysLogMapper;
    @Override
    public void logRecord(SysLog sysLog) {
        SysLogEntity sysLogEntity = new SysLogEntity();
        sysLogEntity.setLogContent(JSON.toJSONString(sysLog));
        sysLogEntity.setCreateTime(sysLog.getCreateTime());
        sysLogMapper.insertLog(sysLogEntity);
    }
}
